package com.tan.common.mapstruct.user;

import com.tan.common.domain.user.SysMenu;
import com.tan.common.dto.user.MenuCreateDTO;
import com.tan.common.dto.user.MenuUpdateDTO;
import com.tan.common.mapstruct.BaseConvert;
import com.tan.common.vo.Option;
import com.tan.common.vo.user.MenuVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author Tan-Bowen
 * @description
 * @date 2025/2/17 11:22
 */
@Mapper
public interface MenuConvert extends BaseConvert<MenuVO, SysMenu> {

    MenuConvert INSTANCE = Mappers.getMapper(MenuConvert.class);

    @Override
    MenuVO toTarget(SysMenu source);


    @Override
    List<MenuVO> toTargets(List<SysMenu> source);


    /**
     * 转成下拉选
     * @param source
     * @return
     */

    List<Option> toOption(List<SysMenu> source);

    @Mapping(source = "id", target = "value")
    @Mapping(source = "name", target = "label")
    @Mapping(source = "parentId", target = "parentId")
    Option toOption(SysMenu sysMenu);


    SysMenu dtoDomain(MenuCreateDTO dto);

    SysMenu dtoDomain(MenuUpdateDTO dto);

}
